package com.ayic.garbagerecycle.controller;

import com.ayic.garbagerecycle.pojo.Result;
import com.ayic.garbagerecycle.pojo.User;
import com.ayic.garbagerecycle.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
@CrossOrigin(origins = "*", allowedHeaders = "*")
@RequestMapping("/register")
@RestController
public class RegisterController {
    @Autowired
    private RegisterService registerService;

    @PostMapping
    public Result register(@RequestBody User user) {
        user.setCreatedAt(LocalDateTime.now());
        user.setRole(3);
        return registerService.register(user);
    }
}
